import 'dart:math' show Random;

import 'package:get/get.dart';
import 'package:abc/view/pagination_list_view.dart';
import 'package:abc/view/video_model.dart';

class WatchHistoryController extends PaginationListController<VideoModel> {
  @override
  Future<List<VideoModel>> loadDatas(int currentPage, int pageSize, bool hasMore) async {
    // 模拟网络请求延迟
    await Future.delayed(Duration(milliseconds: 1000));
    
    // 根据页码生成数据
    List<VideoModel> pageItems = [];
    int startIndex = (currentPage - 1) * pageSize;
    
    // 生成当前页的数据
    for (int i = 0; i < pageSize; i++) {
      final index = startIndex + i;
      
      // 创建一个VideoModel实例
      final video = VideoModel(
        id: index,
        isAd: 0,
        resourceId: 'resource_$index',
        name: '视频标题 $index',
        coverImage: 'assets/images/default_video_cover.png',
        coverImageY: 'assets/images/default_video_cover.png',
        updateStatus:(Random().nextInt(2) + 1).toString(),
        updateStatusText: '更新中',
        duration: '${(index % 10) + 1}:3${index % 10}',
        description: '视频描述 $index',
        previewMvUrl: '',
        mvUrl: '',
        watchNum: (index * 1234) % 100000,
        likeNum: 0,
        realWatchNum: 0,
        realLikeNum: 0,
        commentNum: 0,
        collectNum: 0,
        shareNum: 0,
        isLike: 0,
        tags: ['标签1', '标签2'],
        discount: 0,
        level: 1,
        payType: Random().nextInt(4) + 1,
        price: 0,
        contentType: 0,
     
      );
      
      pageItems.add(video);
    }
    
    return pageItems;
  }
}